'''
A TwistedSim script that shows how to emulate our simple web-server
and web-client under TwistedSim using process-based emulation.

@author: Hatem Oraby
'''
import twistedSim.simManager as simManager 
from twistedSim.contextHandlers import ProcessHandler
from twistedSim.moduleHandler import twistedH

if __name__ == '__main__':

    #Module 1: Echo Server
    serverMachine = simManager.Machine()
    serverInterface = simManager.IpInterface("196.213.32.32", serverMachine)
    serverModule = ProcessHandler('baseServer.py', twistedH())
    simManager.SimManager.addModule(serverModule, serverMachine)
    
    #Module 2: Client 
    clientMachine = simManager.Machine()
    clientInterface = simManager.IpInterface('72.122.125.32', clientMachine)
    clientModule = ProcessHandler('baseClient.py', twistedH(), 
                                  startTime = 100,
                                  sysArgs = "http://196.213.32.32:8080")
    simManager.SimManager.addModule(clientModule, clientMachine)
    
    simManager.SimManager.run()